future proof AWS.Credentials generation
authorJoey Hess <joeyh@joeyh.name>
Mon, 10 Oct 2022 20:31:08 +0000 (16:31 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 10 Oct 2022 20:33:21 +0000 (16:33 -0400)
Avoid breaking when a field is added to the constructor.

Sponsored-by: Dartmouth College's DANDI project
Remote/S3.hs

index 2b6580d69dfeb7a6370e1fcfb3d6d0c58d3c6cd4..1f0ebd3d5a2f71172688d961ab73fed247ddd518 100644 (file)
@@ -33,7 +33,6 @@ import Network.HTTP.Types
 import Network.URI
 import Control.Monad.Trans.Resource
 import Control.Monad.Catch
-import Data.IORef
 import Control.Concurrent.STM (atomically)
 import Control.Concurrent.STM.TVar
 import Data.Maybe
@@ -1071,11 +1070,10 @@ genericPublicUrl baseurl p =
        skipescape c = isUnescapedInURIComponent c
 
 genCredentials :: CredPair -> IO AWS.Credentials
-genCredentials (keyid, secret) = AWS.Credentials
-       <$> pure (tobs keyid)
-       <*> pure (tobs secret)
-       <*> newIORef []
-       <*> (fmap tobs <$> getEnv "AWS_SESSION_TOKEN")
+genCredentials (keyid, secret) = do
+       cr <- AWS.makeCredentials (tobs keyid) (tobs secret)
+       tk <- fmap tobs <$> getEnv "AWS_SESSION_TOKEN"
+       return (cr { AWS.iamToken = tk })
   where
        tobs = T.encodeUtf8 . T.pack